//index.js
//获取应用实例
const app = getApp()
var util = require("../../utils/libs.js")
var api = require("../../utils/api.js")
Page({
  data: {
    groups: [],
  },
  onShareAppMessage: function (res,event) {
    if (res.from === 'button') {
      // 来自页面内转发按钮
      console.log(res.target);
    }
    return {
      title: '',
      path: '',
      success: function (res) {
        wx.showToast({
          title: '分享成功',
          icon: 'success',
          duration: 2000
        })
        return ;
      },
      fail: function (res) {
        // 转发失败
        wx.showToast({
          title: '分享失败',
          icon: 'none',
          duration: 2000
        })
      }
    }
    return false;
  },
  //事件处理函数
  goItem: function(event) {
    if(event.target.id=="") return ;
    var num = event.currentTarget.dataset.num;
    var param = event.currentTarget.dataset.type;
    if(num==0){
      wx.showToast({
        title: '暂无文章',
        icon: 'none',
        duration: 2000
      })
      return;
    }
      wx.navigateTo({
        url: '../cities/cities?param='+param
      })
    
  },
  onLoad: function () {
    let that = this
    util.request(api.select, {}, "POST")
      .then(function (res) {
        if (res.error_code === 0) {
          console.log(res)
          that.setData({
            groups: res.data.list
          })
        }
      })
  }
  
})
